<template>
  <div class="container-content">
    <el-form
      ref="formRef"
      :model="formObject"
      label-width="100px"
      label-position="left"
      class="mt20"
    >
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="仓库名称">
            <el-input v-model="formObject.wareName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="仓库编码">
            <el-input v-model="formObject.wareCode"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="地址">
            <el-input v-model="formObject.address"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系电话">
            <el-input v-model="formObject.telPhone"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="备注">
            <el-input v-model="formObject.remarks" type="textarea"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { addWareList, editList, getDetailList } from "@/api/system/warehouse";
export default {
  props: ["id"],
  data() {
    return {
      formObject: {
        address: "",
        changeTime: "",
        createTime: "",
        id: "",

        limit: 0,
        page: 0,
        projectId: "",
        remarks: "",
        telPhone: "",
        token: "",
        userId: "",
        wareCode: "",
        wareManagement: "",
        wareName: "",
      },
    };
  },
  methods: {
    onSubmit() {
      if (this.id) {
        editList(this.formObject).then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "修改成功！",
              type: "success",
            });
          }
        });
      } else {
        addWareList(this.formObject).then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "新增成功！",
              type: "success",
            });
          }
        });
      }
    },
    getData(id) {
      getDetailList(id).then((res) => {
        this.formObject = res.data;
      });
    },
  },
  created() {
    if (this.id) {
      this.getData(this.id);
    }
  },
};
</script>
<style lang="scss" scoped>
.divider {
  margin: 0;
}
</style>
